#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(int argc, const char *argv[])
{
	int fd[2];
	pipe(fd);

	pid_t pid=fork();
	if(pid>0)
	{
		close(fd[1]);
		while(1)
		{			
			char readbuf[32]={0};
			while(read(fd[0],readbuf,sizeof(readbuf))>0)
			{
				printf("%s\n",readbuf);
			}
			memset(readbuf,32,0);

		}
	}
	else if(pid==0)
	{
		close(fd[0]);
		while(1)
		{
			char writebuf[32]={0};
			scanf("%s",writebuf);
			write(fd[1],writebuf,strlen(writebuf));
			memset(writebuf,32,0);

		}
	}

	return 0;
}
